/*
*
*/

#include <stdlib.h>
#include <stdio.h>

#define ds_video_c
#define LUA_LIB

#include "vars.h"

static int video_3DEnabled(lua_State *L){
	lua_pushboolean(L, (REG_DISPCNT & ENABLE_3D) ? true : false);
	return 1;
}

static int video_setBackdropColor(lua_State *L){
	int color = (int)luaL_checknumber(L, 1);
	BG_PALETTE[0] = color;
	return 0;
}

static int video_setBackdropColorSub(lua_State *L){
	int color = (int)luaL_checknumber(L, 1);
	BG_PALETTE_SUB[0] = color;
	return 0;
}

static int video_setMode(lua_State *L){
	int mode = (int)luaL_checknumber(L, 1);
	videoSetMode(mode);
	return 0;
}

static int video_setModeSub(lua_State *L){
	int mode = (int)luaL_checknumber(L, 1);
	videoSetModeSub(mode);
	return 0;
}

static int video_b(lua_State *L){
	return 0;
}

static const luaL_Reg videolib[] = {
	{"3DEnabled", video_3DEnabled},
	{"setBackdropColor", video_setBackdropColor},
	{"setBackdropColorSub", video_setBackdropColorSub},
	{"setMode", video_setMode},
	{"setModeSub", video_setModeSub},
	{"b", video_b},
	{NULL, NULL}
};

/*
** Open infos library
*/
LUALIB_API int luaopen_video (lua_State *L) {
	luaL_register(L, LUA_VIDEOLIBNAME, videolib);
	return 1;
}

